<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ include file="../include/laypublic.jsp" %>
<!DOCTYPE html>
<html>
<head>
    <title>营销奖励详情</title>
</head>
<style>
    .fieldset {
        margin-top: 5px;
        margin-bottom: 0px
    }

    .layui-legend {
        background-color: #5fb878;
        font-size: 15px !important;
        width: 140px;
    }

    .layui-form-item {
        margin-bottom: 5px;
        clear: both;
        *zoom: 1;
    }

    .layui-form-label {
        width: 180px;
    }
</style>
<body>
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-tab-item layui-show">
            <div class="layui-card">
                <div class="layui-card-body">
                    <div class="layui-tab layui-tab-brief" lay-filter="component-tabs-brief">
                        <div class="layui-tab-content">
                            <div class="layui-tab-item layui-show">
                                <!-- start 业务表单数据显示  put yourself data here -->
                                <form class="layui-form" id="addInfo_form">
                                    <button type="button" type="button" class="layui-btn layui-btn-primary layui-btn-radius" lay-submit lay-filter="addInfo_form_submit" id="addInfo_form_submit2">保存</button>
                                    <button type="button" type="button" class="layui-btn layui-btn-radius" lay-submit lay-filter="addInfo_form_submit" id="addInfo_form_submit">提交</button>
                                    <input type="hidden" name="id" value="${ marketingRewardDomain.id }" />
                                    <fieldset class="layui-elem-field layui-field-title fieldset" id="baseInfo">
                                        <legend class="layui-btn layui-legend" style="text-align:left;cursor:default;">
                                            项目基础信息 >
                                        </legend>
                                        <div style="margin-top:20px">
                                            <div class="layui-form-item">
                                                <div class="layui-inline">
                                                    <label class="layui-form-label">项目名称</label>
                                                    <div class="layui-input-inline">
                                                        <input type="text" name="proName"
                                                               value="${ marketingRewardDomain.proName }" style="border:0px;"
                                                               readonly="readonly" class="layui-input">
                                                    </div>
                                                </div>
                                                <div class="layui-inline">
                                                    <label class="layui-form-label">市场区域</label>
                                                    <div class="layui-input-inline">
                                                        <input type="text" name="sgCityName"
                                                               value="${ marketingRewardDomain.sgCityName }" style="border:0px;"
                                                               readonly="readonly" class="layui-input">
                                                    </div>
                                                </div>
                                                <div class="layui-inline">
                                                    <label class="layui-form-label">项目编码</label>
                                                    <div class="layui-input-inline">
                                                        <input type="text" name="proCode"
                                                               value="${ marketingRewardDomain.proCode }" readonly="readonly"
                                                               style="border:0px" class="layui-input">
                                                    </div>
                                                </div>
                                                <div class="layui-inline">
                                                    <label class="layui-form-label">总投资额</label>
                                                    <div class="layui-input-inline">
                                                        <input type="text" name="sumAmount"
                                                               value="${ marketingRewardDomain.sumAmount }" style="border:0px;"
                                                               readonly="readonly" class="layui-input">
                                                    </div>
                                                </div>
                                                <div class="layui-inline">
                                                    <label class="layui-form-label">营销经理</label>
                                                    <div class="layui-input-inline">
                                                        <input type="text" name="staffName"
                                                               value="${ marketingRewardDomain.staffName }" style="border:0px;"
                                                               readonly="readonly" class="layui-input">
                                                    </div>
                                                </div>
                                                <div class="layui-inline">
                                                    <label class="layui-form-label">建安额（万）</label>
                                                    <div class="layui-input-inline">
                                                        <input type="text" name="sumCae" value="${ marketingRewardDomain.sumCae }"
                                                               style="border:0px;" readonly="readonly"
                                                               class="layui-input">
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </fieldset>

                                    <fieldset class="layui-elem-field layui-field-title fieldset" id="awardInfo">
                                        <legend class="layui-btn layui-legend" style="text-align:left;cursor:default;">
                                            投标信息 >
                                        </legend>
                                        <div style="margin-top:20px">
                                            <div class="layui-form-item">
                                                <div class="layui-inline">
                                                    <label class="layui-form-label">中标通知书日期</label>
                                                    <div class="layui-input-inline">
                                                        <input type="date" class="layui-input" name="bondNotifyDate" placeholder="年/月/日"
                                                               value="<fmt:formatDate value="${ marketingRewardDomain.bondNotifyDate }" pattern="yyyy-MM-dd"/>">
                                                    </div>
                                                </div>
                                                <div class="layui-inline">
                                                    <label class="layui-form-label">中标日期</label>
                                                    <div class="layui-input-inline">
                                                        <input type="date" class="layui-input" name="bondDate" placeholder="年/月/日"
                                                               value="<fmt:formatDate value="${ marketingRewardDomain.bondDate }" pattern="yyyy-MM-dd"/>">
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="layui-form-item">
                                                <div class="layui-inline">
                                                    <label class="layui-form-label">申请奖金金额</label>
                                                    <div class="layui-input-inline">
                                                        <input type="text" name="rewardAmount" value="${ marketingRewardDomain.rewardAmount }" autocomplete="off" class="layui-input">
                                                    </div>
                                                </div>
                                                <div class="layui-inline">
                                                    <label class="layui-form-label">占总奖金比例</label>
                                                    <div class="layui-input-inline">
                                                        <input type="text" name="rewardRate" value="${ marketingRewardDomain.rewardRate }" autocomplete="off" class="layui-input">
                                                    </div>
                                                </div>
                                                <div class="layui-inline">
                                                    <label class="layui-form-label">融资情况</label>
                                                    <div class="layui-input-inline">
                                                        <textarea name="capMemo" style="width: 600px;height: 60px" placeholder="请说明融资情况" autocomplete="off">${ marketingRewardDomain.capMemo }</textarea>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </fieldset>

                                    <fieldset class="layui-elem-field layui-field-title"
                                              style="margin-top: 15px;">
                                        <legend class="layui-btn layui-legend"
                                                style="text-align: left; cursor: default;">
                                            项目附件信息 > <label class="layui-form-label" style="width: 100%;">支持pdf、excel、word、图片资料，可上传多个
                                        </label>
                                        </legend>
                                    </fieldset>
                                    <div class="layui-form-item" style="margin-top: 10px;">
                                        <label class="layui-form-label">附件资料</label>
                                        <div class="layui-input-block">
                                            <div class="layui-upload">
                                                <button type="button" class="layui-btn" id="upload-more">上传文件</button>
                                                <div class="layui-upload-list" id="upload-more-list"></div>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="layui-form-item layui-hide">
                                        <input type="button" lay-submit
                                               lay-filter="flow_process_from_submit"
                                               id="flow_process_from_submit" value="确认">
                                    </div>
                                </form>
                            </div>
                            <!-- 引入公共流程渲染页面   -->
                            <%@ include file="../include/flowPublic.jsp" %>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    layui.config({
        base: '${ctx}/resources/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'table', 'set', 'transfer', 'upload'], function () {
        var $ = layui.$
            , upload = layui.upload
            , table = layui.table
            , form = layui.form;

        upload.render({
            elem: '#upload-more'
            ,
            url: basePath + '/marketingReward/uploadAtt/'
            ,
            multiple: true
            ,
            accept: 'file'
            ,
            acceptMime: 'application/zip,application/x-rar-compressed,image/jpeg,image/png,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.ms-powerpoint,application/vnd.openxmlformats-officedocument.presentationml.presentation,application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/pdf'
            ,
            before: function (obj) { //obj参数包含的信息
                layer.load(); //上传loading
            }
            ,
            done: function (res) {
                //如果上传失败
                if (res.code > 0) {
                    layer.closeAll('loading'); //关闭loading
                    return layer.msg(res.msg, {icon: 7});
                }
                //上传完毕
                if (res.entity != null && res.entity.length > 0) {
                    for (var i in res.entity) {
                        var askBillAtt = res.entity[i];
                        var arr = askBillAtt.split("|");
                        var imgSrc = "";
                        var suffix = arr[0].substring(arr[0].lastIndexOf(".") + 1, arr[0].length);
                        if (suffix == 'jpg' || suffix == 'png') {
                            imgSrc = "${fileHttpPre}/" + arr[2];
                        } else {
                            imgSrc = "${ctx}/resources/images/" + suffix + ".jpg";
                        }
                        $('#upload-more-list').append('<div class="layui-upload-img-div" id="upload_img_' + arr[1] + '"><img src="' + imgSrc + '" title="' + arr[0] + '" class="layui-upload-img"><div class="mask"><a href="javascript:void(0)" onclick="showImg(\'' + "${fileHttpPre}" + arr[2] + '\');">查看</a><a href="javascript:void(0)" onclick="del(\'' + arr[1] + '\')";>删除</a></div><p>' + arr[0] + '</p><input type="hidden" value="' + askBillAtt + '" id="fileAtt_' + arr[1] + '" name="fileAtt" ></input></div> ');
                    }
                }
            }
            ,
            allDone: function (obj) { //当文件全部被提交后，才触发
                layer.closeAll('loading'); //关闭loading
            }
            ,
            error: function () {
                layer.closeAll('loading'); //关闭loading
                //上传失败
                layer.msg("上传失败，请稍后再试~", {icon: 7});
            }
        });

        //监听提交
        form.on('submit(addInfo_form_submit)', function(data){
            var btnId=data.elem.id
            $("#"+btnId).removeAttr("lay-submit").removeClass("layui-bg-blue").addClass("layui-btn-disabled");
            if(btnId=='addInfo_form_submit'){
                $("#submitType").val('2');
            }else{
                $("#submitType").val('1');
            }
            var url='/marketingReward/save';

            $.ajax({
                type : 'post',
                url : basePath + url,
                data: $('#addInfo_form').serialize(),
                success:function(result){
                    if(result.success){
                        layer.closeAll('loading'); //关闭loading
                        layer.msg('提交单据成功~',{icon: 1});
                        //两秒后关闭当前页面
                        setTimeout(function(){
                            /**
                             * 查找父菜单，并刷新
                             */
                            var topDoc = $(window.top.document);
                            var path = basePath + '/marketingReward/list';
                            // 获取页面名称
                            var name = topDoc.find(".layui-nav-item [lay-href^='" + path + "']").text();
                            if(name == '' || name == null){
                                name = '营销奖励';
                            }
                            window.parent.layui.index.openTabsPage(path, name);
                            var iframe = window.parent.layui.admin.tabsBody(window.parent.layui.admin.tabsPage.index).find(".layadmin-iframe");
                            iframe[0].contentWindow.location.reload(true);

                            /**
                             * 关闭当前页
                             */
                            if(data.field.id&&data.field.id!=''){
                                currPath = basePath + '/marketingReward/toDetail?id='+data.field.id;
                            }else{
                                currPath = basePath + '/marketingReward/add';
                            }
                            var layid = topDoc.find("li[lay-id^='" + currPath + "']").attr('lay-id');
                            window.parent.layui.element.tabDelete('layadmin-layout-tabs', layid);//关闭当前页
                        }, 2000);
                    }else{
                        layer.closeAll('loading'); //关闭loading
                        $("#addInfo_form_submit").removeClass("layui-btn-disabled").addClass("layui-bg-blue").attr("lay-submit","");
                        layer.msg(result.msg,{icon: 7});
                    }
                }
            });
        });
        // data-type事件
        $('.layui-btn.layuiadmin-btn-admin').on('click', function(){
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });

    });

    //删除文件
    function del(index) {
        layui.$("#fileAtt_" + index).remove();
        layui.$("#upload_img_" + index).remove();
    }

    //根据url查看文件
    function showImg(url) {
        var openWin = window.open(url, '', 'left=410,height=768, width=1024, top=200,  toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no');
    }

</script>
</body>
</html>

